package com.fengke.service.vo;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.fengke.util.Constants;

public class PageBean {
	/**
	 * 当前页码/待请求页码
	 */
	private Integer currentPage=1;
	/**
	 * 每页显示数量
	 */
	private Integer pageSize = Constants.PageSize.CSC_PAGE_SIZE;
	/**
	 * 页数
	 */
	private Integer pageCount=0;
	/**
	 * 结果集数量
	 */
	private Integer resultItemCount=0;
	/**
	 * 展示起始值
	 */
	private Integer startIndex=0;
	/**
	 * 展示终止值
	 */
	private Integer endIndex=0;
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
	public Integer getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Integer getPageCount() {
		return pageCount;
	}
	public void setPageCount(Integer pageCount) {
		this.pageCount = pageCount;
	}
	public Integer getResultItemCount() {
		return resultItemCount;
	}
	public void setResultItemCount(Integer resultItemCount) {
		this.resultItemCount = resultItemCount;
		this.pageCount = (this.resultItemCount / this.pageSize) + (this.resultItemCount % this.pageSize == 0 ? 0 : 1);
		this.startIndex = (this.currentPage - 1) * this.pageSize + 1;
		this.endIndex = this.startIndex + this.pageSize - 1;
		if(this.endIndex > this.resultItemCount) {
			this.endIndex = this.resultItemCount;
		}
	}
	public Integer getStartIndex() {
		return startIndex;
	}
	public void setStartIndex(Integer startIndex) {
		this.startIndex = startIndex;
	}
	public Integer getEndIndex() {
		return endIndex;
	}
	public void setEndIndex(Integer endIndex) {
		this.endIndex = endIndex;
	}
}
